function Map = fsb_map_overlay(Map)

% FSB - DEV : Overlay map on anatomical image
%
% EXAMPLE: Map = fsb_map_overlay(Map)
%
% INPUT:
% Map: Map map struct with the fields
% Map.slice_data
% Map.tsfx : Scale in x
% Map.tsfy : Scale in y
% Map.shiftx : Shift in x
% Map.shifty : Shift in y
%
% OUTPUT:
% Map.tzi: Transparency map
% Map.zmt: Color coded statistical map
%
% CALLED BY:
% FSB.m
% fsb_functional_map.m
%
% NOTES:
% Adjusts in plane size to fit overlay, in development
%
% Copyright 2010 MPI for Biological Cybernetics
% Author: Steffen Stoewer
% License:GNU GPL, no express or implied warranties
% 
% $Revision 1.0
%
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Map.zmt = [];

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Check if overlay size is same as image size and scale functional map if necessary
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if Map.slice_data(1:2)~=Map.zm(1:2);
    for xi = 1:size(Map.zm,3);
        Map.zmt(:,:,xi) = fsb_resize_idat(squeeze(Map.zm(:,:,xi)), Map.slice_data,...
            Map.tsfx,Map.tsfy,Map.shiftx,Map.shifty,0);
    end
else
    Map.zmt = Map.zm;
end

Map.zm = Map.zmt;
Map.zm(Map.zm>1)=1;
Map.zm(Map.zm<0)=0;

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Check if overlay size is same as image size and scale transparency map if necessary
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if Map.slice_data(1:2)~=Map.zm(1:2);   
    Map.tzi = fsb_resize_idat(Map.tzi, Map.slice_data,Map.tsfx,Map.tsfy,Map.shiftx,Map.shifty,0);
end

Map.tzi = int16(Map.tzi);

end
